// import Vue from 'vue'
// import Vuex from 'vuex'
const Vue = require('vue')
const Vuex = require('vuex')

Vue.use(Vuex)

const state = {
  user: {
    openId: null, //登录授权key
    uid: 0
  }
}

const mutations = {
  /**
   * 初始化用户信息
   * @param {*} state
   * @param {*} rsp
   */
  initUser(state, rsp) {
    state.user.openId = rsp.openId
    state.user.uid = rsp.uid
  }
}

const getters = {
  user(state) {
    return state.user
  }
}

export default new Vuex.Store({
  state,
  mutations,
  getters
})
